package com.liy.cloud.common.trade.entity;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

import com.liy.cloud.common.exception.NegativeNumberException;
import com.das.framework.common.vo.SupportVO;

/**
 * @Author: liyang
 * @Date: 2018/8/22 16:52
 **/
public class TradeCommEntity extends SupportVO<String> implements Serializable {
    
	protected static final long serialVersionUID = 1L;

	protected String version; // 版本
	protected String operator; // 操作员
	protected String testFlag; // 测试交易标识
	protected String greyFlag; // 灰交易标识
	protected Long deviceSum; // 设备总金额

	protected String IndustrySplit; // 行业分割标识
	protected String IndustryData; // 行业数据
	protected Long IndustryDataLength; // 行业数据长度
	protected String crc16; // CRC16校验
	protected String issuer; // 发行方

	protected String commId; // 子表中引用的主表ID
	
	/**
	 * SZMETROV3版本修改------start
		 * 一、V3卡号由9位变为20位
		 * 二、增加字段：
			           付费方式
				支付方式
				发卡方机构码
				发卡方交易流水号
				运营模式
		      三、票卡发行方标识	从长度4变为长度2
	 */
	protected String payMethod;	// 长度1，付费方式：0预付费1后付费
	protected String payType;	// 长度2，支付方式：00票方	01现金	02微信	03支付宝	04银联
	protected String issuerCode;// 长度8,右补空格，发卡方机构码
	protected String issuerSeq;	// 长度10，发卡方交易流水号
	protected String operMode;	// 长度4，运营模式：标识是否为降级模式下的交易
	/**
	 * SZMETROV3版本修改-----end
	 */


    protected String queryStartTime;  // 条件查询开始时间
    protected String queryEndTime;    // 条件查询结束时间

	/*
	 * 卡号
	 */
	protected String cardId;

	/*
	 * 交易时间
	 */
	protected String tradeTime;

	/*
	 * 卡序号
	 */
	protected Long cardSeq;

	/*
	 * 设备终端编号
	 */
	protected String deviceId;

	/*
	 * TAC码
	 */
	protected String tac;

	/*
	 * 卡类型编码 (票或卡类型)
	 */
	protected String cardCode;

	// 卡类型编码-名称
    protected String cardCodeName;

	/*
	 * 交易类型编码
	 */
	protected String tradeCode;

    /**
     * @Author:  liyang
     * @Date:    2018/8/30  14:04
     * @Description:  支持传入多个tradeCode值 查询时使用
     *
     **/
    private List<String> tradeCodes;


	// 交易类型编码-名称
    protected String tradeCodeName;

	/*
	 * 票卡余额
	 */
	protected Long balance;

	/*
	 * 交易金额
	 */
	protected Long tradeMoney;

	/*
	 * 交易值
	 */
	protected Long tradeValue;

	/*
	 * 押金
	 */
	protected Long deposit;

	/*
	 * 费用
	 */
	protected Long cost;

	/*
	 * 物理介质
	 */
	protected String media;

	/*
	 * 交易小类
	 */
	protected String tradeSub;

	/*
	 * 交易站点
	 */
	protected String tradeAddress;

	/*
	 * 接收时间
	 */
	protected String recvTime;

	/*
	 * 终端交易序号
	 */
	protected Long deviceSeq;

	/*
	 * 票卡物理号
	 */
	protected String physicalId;

	/*
	 * SAM卡卡号
	 */
	protected String samcardId;

	/*
	 * SAM卡卡序号
	 */
	protected Long samcardSeq;

	/*
	 * 卡版本号
	 */
	protected String cardVersion;

	/*
	 * 卡子类型
	 */
	protected String subCardCode;

	// 卡子类型
    protected String subCardCodeName;

	/*
	 * 城市代码
	 */
	protected String cityCode;

	// 城市代码-名称
    protected String cityCodeName;

	/*
	 * 行业代码
	 */
	protected String businessCode;


    /**
     * 日期格式验证
     *
     * @author shitou
     * @param tradeTime2
     * @throws ParseException
     */
    private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");

    protected void checkTimeStyle(String tradeTime, String field) throws ParseException {
        try {
            sdf.parse(tradeTime);
        } catch (ParseException e) {
            throw new ParseException("日期格式[" + field + "]转换错误:" + e.getMessage(), e.getErrorOffset());
        }
    }

    /**
     * 金额格式验证，大于等于0
     *
     * @author shitou
     * @param
     * @param field
     * @throws ParseException
     */
    protected void checkMoneyStyle(Long money, String field) throws NegativeNumberException {

        if (money == null || money < 0) {
            throw new NegativeNumberException("金额格式[" + field + "]小于零：" + money);
        }
    }

    /**
     * 数字格式验证，大于等于0
     *
     * @author shitou
     * @param
     * @param field
     * @throws ParseException
     */
    protected void checkNumberStyle(Long number, String field) throws NegativeNumberException {

        if (number == null || number < 0) {
            throw new NegativeNumberException("数量格式[" + field + "]小于零：" + number);
        }
    }

    public TradeCommEntity(){super();}

    /**
    *  有参构造:
     * @param  tradeAddress  交易车站
     * @param  tradeCode     交易类型编码
     * @param  recvTime      接收时间
    **/
    public TradeCommEntity(String tradeAddress,String tradeCode,String recvTime){
        this.tradeAddress = tradeAddress;
        this.recvTime = recvTime;
        this.tradeCode = tradeCode;
    }

    /**
     *  有参构造:
     * @param  tradeAddress  交易车站
     * @param  tradeCodes    交易类型编码集合
     * @param  recvTime      接收时间
     **/
    public TradeCommEntity(String tradeAddress,List<String> tradeCodes,String recvTime){
        this.tradeAddress = tradeAddress;
        this.recvTime = recvTime;
        this.tradeCodes = tradeCodes;
    }

    /**
     *  有参构造:
     * @param  tradeAddress  交易车站
     * @param  tradeCode     交易类型
     * @param  recvTime      接收时间
     * @param  deviceId      交易类型
     * @param  cardCode      票卡类型( 票或者卡) itemId
     **/
    public TradeCommEntity(String tradeAddress,String tradeCode,String recvTime,String deviceId,String cardCode ){
        this.tradeAddress = tradeAddress;
        this.tradeCode = tradeCode;
        this.recvTime = recvTime;
        this.deviceId = deviceId;
        this.cardCode = cardCode;
    }

    /**
     *  有参构造:
     * @param  tradeAddress  交易车站
     * @param  tradeCode     交易类型
     * @param  recvTime      接收时间
     * @param  deviceId      终端设备编号
     **/
    public TradeCommEntity(String tradeAddress,String tradeCode,String recvTime,String deviceId){
        this.tradeAddress = tradeAddress;
        this.tradeCode = tradeCode;
        this.recvTime = recvTime;
        this.deviceId = deviceId;
    }


    /**
     * getger和setter方法
     */

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getOperator() {
        return operator;
    }

    public void setOperator(String operator) {
        this.operator = operator;
    }

    public String getTestFlag() {
        return testFlag;
    }

    public void setTestFlag(String testFlag) {
        this.testFlag = testFlag;
    }

    public String getGreyFlag() {
        return greyFlag;
    }

    public void setGreyFlag(String greyFlag) {
        this.greyFlag = greyFlag;
    }

    public Long getDeviceSum() {
        return deviceSum;
    }

    public void setDeviceSum(Long deviceSum) throws NegativeNumberException {
        checkMoneyStyle(deviceSum, "DeviceSum");
        this.deviceSum = deviceSum;
    }

    public String getIndustrySplit() {
        return IndustrySplit;
    }

    public void setIndustrySplit(String industrySplit) {
        IndustrySplit = industrySplit;
    }

    public String getIndustryData() {
        return IndustryData;
    }

    public void setIndustryData(String industryData) {
        IndustryData = industryData;
    }

    public Long getIndustryDataLength() {
        return IndustryDataLength;
    }

    public void setIndustryDataLength(Long industryDataLength) {
        IndustryDataLength = industryDataLength;
    }

    public String getCrc16() {
        return crc16;
    }

    public void setCrc16(String crc16) {
        this.crc16 = crc16;
    }

    public String getIssuer() {
        return issuer;
    }

    public void setIssuer(String issuer) {
        this.issuer = issuer;
    }

    public String getCommId() {
        return commId;
    }

    public void setCommId(String commId) {
        this.commId = commId;
    }

    public String getQueryStartTime() {
        return queryStartTime;
    }

    public void setQueryStartTime(String queryStartTime) {
        this.queryStartTime = queryStartTime;
    }

    public String getQueryEndTime() {
        return queryEndTime;
    }

    public void setQueryEndTime(String queryEndTime) {
        this.queryEndTime = queryEndTime;
    }

    public String getCardId() {
        return cardId;
    }

    public void setCardId(String cardId) {
        this.cardId = cardId;
    }

    public String getTradeTime() {
        return tradeTime;
    }

    public void setTradeTime(String tradeTime) throws ParseException {
        checkTimeStyle(tradeTime, "TradeTime");
        this.tradeTime = tradeTime;
    }

    public Long getCardSeq() {
        return cardSeq;
    }

    public void setCardSeq(Long cardSeq) {
        this.cardSeq = cardSeq;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getTac() {
        return tac;
    }

    public void setTac(String tac) {
        this.tac = tac;
    }

    public String getCardCode() {
        return cardCode;
    }

    public void setCardCode(String cardCode) {
        this.cardCode = cardCode;
    }

    public String getCardCodeName() {
        return cardCodeName;
    }

    public void setCardCodeName(String cardCodeName) {
        this.cardCodeName = cardCodeName;
    }

    public String getTradeCode() {
        return tradeCode;
    }

    public void setTradeCode(String tradeCode) {
        this.tradeCode = tradeCode;
    }

    public String getTradeCodeName() {
        return tradeCodeName;
    }

    public void setTradeCodeName(String tradeCodeName) {
        this.tradeCodeName = tradeCodeName;
    }

    public Long getBalance() {
        return balance;
    }

    public void setBalance(Long balance) {
        this.balance = balance;
    }

    public Long getTradeMoney() {
        return tradeMoney;
    }

    public void setTradeMoney(Long tradeMoney) throws NegativeNumberException {
        checkMoneyStyle(tradeMoney, "TradeMoney");
        this.tradeMoney = tradeMoney;
    }

    public Long getTradeValue() {
        return tradeValue;
    }

    public void setTradeValue(Long tradeValue) throws NegativeNumberException {
        checkMoneyStyle(tradeValue, "TradeValue");
        this.tradeValue = tradeValue;
    }

    public Long getDeposit() {
        return deposit;
    }

    public void setDeposit(Long deposit) throws NegativeNumberException {
        checkMoneyStyle(deposit, "Deposit");
        this.deposit = deposit;
    }

    public Long getCost() {
        return cost;
    }

    public void setCost(Long cost) throws NegativeNumberException {
        checkMoneyStyle(cost, "Cost");
        this.cost = cost;
    }

    public String getMedia() {
        return media;
    }

    public void setMedia(String media) {
        this.media = media;
    }

    public String getTradeSub() {
        return tradeSub;
    }

    public void setTradeSub(String tradeSub) {
        this.tradeSub = tradeSub;
    }

    public String getTradeAddress() {
        return tradeAddress;
    }

    public void setTradeAddress(String tradeAddress) {
        this.tradeAddress = tradeAddress;
    }

    public String getRecvTime() {
        return recvTime;
    }

    public void setRecvTime(String recvTime) {
        this.recvTime = recvTime;
    }

    public Long getDeviceSeq() {
        return deviceSeq;
    }

    public void setDeviceSeq(Long deviceSeq) {
        this.deviceSeq = deviceSeq;
    }

    public String getPhysicalId() {
        return physicalId;
    }

    public void setPhysicalId(String physicalId) {
        this.physicalId = physicalId;
    }

    public String getSamcardId() {
        return samcardId;
    }

    public void setSamcardId(String samcardId) {
        this.samcardId = samcardId;
    }

    public Long getSamcardSeq() {
        return samcardSeq;
    }

    public void setSamcardSeq(Long samcardSeq) {
        this.samcardSeq = samcardSeq;
    }

    public String getCardVersion() {
        return cardVersion;
    }

    public void setCardVersion(String cardVersion) {
        this.cardVersion = cardVersion;
    }

    public String getSubCardCode() {
        return subCardCode;
    }

    public void setSubCardCode(String subCardCode) {
        this.subCardCode = subCardCode;
    }

    public String getSubCardCodeName() {
        return subCardCodeName;
    }

    public void setSubCardCodeName(String subCardCodeName) {
        this.subCardCodeName = subCardCodeName;
    }

    public String getCityCode() {
        return cityCode;
    }

    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }

    public String getCityCodeName() {
        return cityCodeName;
    }

    public void setCityCodeName(String cityCodeName) {
        this.cityCodeName = cityCodeName;
    }

    public String getBusinessCode() {
        return businessCode;
    }

    public void setBusinessCode(String businessCode) {
        this.businessCode = businessCode;
    }

    public List<String> getTradeCodes() {
        return tradeCodes;
    }

    public void setTradeCodes(List<String> tradeCodes) {
        this.tradeCodes = tradeCodes;
    }

	public String getPayMethod() {
		return payMethod;
	}

	public void setPayMethod(String payMethod) {
		this.payMethod = payMethod;
	}

	public String getPayType() {
		return payType;
	}

	public void setPayType(String payType) {
		this.payType = payType;
	}

	public String getIssuerCode() {
		return issuerCode;
	}

	public void setIssuerCode(String issuerCode) {
		this.issuerCode = issuerCode;
	}

	public String getIssuerSeq() {
		return issuerSeq;
	}

	public void setIssuerSeq(String issuerSeq) {
		this.issuerSeq = issuerSeq;
	}

	public String getOperMode() {
		return operMode;
	}

	public void setOperMode(String operMode) {
		this.operMode = operMode;
	}
    
    
}
